- /* srffcomp.cpp by K.Tsuru */
- // function ID = 8001 BRADIX
- /****************************************************************
- SRational class
- return sgn(|m| - |n|) = 1, 0 , -1
- m = m.num/m.den; n = n.num/n.den;
- |m| - |n| = ( |m.num|*n.den - m.den*|n.num| ) / (m.den*n.den);
- ****************************************************************/
- #ifndef SN_H
- #include "sn.h"
- #endif
- int RRCompare(const SRational& m, const SRational& n){
- //It checks the diffrence of figures.
- //99*99 (2+2) = 891*11 (3+2) : error is one figure
- int df;
- df = (int)(m.NumNR().Head()+n.DenNR().Head()) - int(m.DenNR().Head()+n.NumNR().Head());
- if(abs(df) > 1) return Sgn(df); //clearly diffrent
-
- SInteger a, b;
- a = m.NumNR()*n.DenNR(); b = m.DenNR()*n.NumNR();
- return LLCompare(a, b);
- }
srrrcomp.cpp : last modifiled at 2015/12/03 21:23:13(792 bytes)
created at 2016/06/26 15:57:35
The creation time of this html file is 2016/09/18 20:28:05 (Sun Sep 18 20:28:05 2016).